package com.un.ebs.sys.mapper;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.un.ebs.sys.domain.EntPersonnel;
import com.un.ebs.sys.domain.Personnel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author liubo
 * @since 2020-03-07
 */
@Component
public interface PersonnelMapper extends BaseMapper<Personnel> {
    @Select("select isnull(max(sort)+1,1) from sys_personnel")
    int maxSort();

    @SqlParser(filter = true)
    @Select("select * from sys_ent_personnel where is_delete=0 and ent_id=#{entId} and personnel_id=#{personnelId}")
    EntPersonnel queryByEntAndPersonnel(@Param("entId") String entId, @Param("personnelId") String personnelId);

    @SqlParser(filter = false)
    @Select("select top 1 * from sys_personnel where tel=#{phone}")
    Personnel queryByPhone(@Param("phone") String phone);
}
